Skip to content

Conversation

@dizer-ti
Copy link
Contributor

In Base64 decode validation, bytes 'a', 'b', and 'c' properly shift the error parameter with shl(248, ...) before storing, but byte 'd' was missing this operation. This caused incorrect ABI encoding when the 4th byte in a chunk was invalid.

Changed line 211 from:
mstore(4, add(d, 43))
to:
mstore(4, shl(248, add(d, 43)))

@dizer-ti dizer-ti requested a review from a team as a code owner November 17, 2025 17:51
@changeset-bot
Copy link

changeset-bot bot commented Nov 17, 2025

⚠️ No Changeset found

Latest commit: ff972aa

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 17, 2025

Walkthrough

The change modifies the Base64 decoding logic in contracts/utils/Base64.sol specifically for 4-byte input chunk processing. The fourth decoded byte is now left-shifted by 248 bits before being stored in the 32-byte memory word at offset 4. This repositions the decoded value from the least significant portion to the most significant byte of the word. The surrounding control flow and error handling logic remain unaffected.

Possibly related PRs

  • Base64.decode #5765: Directly modifies the same Base64 decode assembly logic for 4-byte chunk handling.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: correcting error encoding for the 4th byte in Base64 decode validation, which is the primary focus of this bugfix.
Description check ✅ Passed The description is directly related to the changeset, explaining the bug (missing shl(248, ...) on byte 'd'), the specific line changed, and the correct fix applied.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6308fdc and ff972aa.

📒 Files selected for processing (1)
  • contracts/utils/Base64.sol (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Redirect rules - solidity-contracts
  • GitHub Check: Header rules - solidity-contracts
  • GitHub Check: Pages changed - solidity-contracts
  • GitHub Check: halmos
  • GitHub Check: coverage
  • GitHub Check: tests-foundry
  • GitHub Check: slither
  • GitHub Check: tests-upgradeable
  • GitHub Check: tests
🔇 Additional comments (1)
contracts/utils/Base64.sol (1)

207-213: LGTM! Critical bug fix for correct ABI encoding.

This change correctly applies shl(248, ...) to byte d, making it consistent with the error encoding for bytes a, b, and c (lines 190, 197, 204). The shift positions the invalid character in the most significant byte of the 32-byte word, which is required for proper ABI encoding of the bytes1 parameter in the InvalidBase64Char(bytes1) error. Without this shift, the error data would be malformed when the 4th byte of a chunk was invalid.

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example:

"Create a concise high-level summary as a bullet-point list. Then include a Markdown table showing lines added and removed by each contributing author."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant